home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE10 / BLINDTRS / LINE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  25KB  |  759 lines

  1.  
  2. #include <windows.h> 
  3. #include <windowsx.h> 
  4. #include "line.h" 
  5. #include "tapi.h"
  6.  
  7. #define BUFSIZE 256
  8. #define APIHIVERSION     0x00010028    /* 1.40 */
  9. #define APILOWVERSION    0x00010000    /* 1.0 */
  10. #define EXTHIVERSION     0x00010005    /* 1.5 */
  11. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  12. #define OWNER        0
  13. #define MONITOR      1
  14. #define MAX_CALL        3
  15. #define MAX_LINE        2
  16.  
  17.  
  18. #if defined (WIN32)
  19.     #define IS_WIN32 TRUE
  20. #else
  21.     #define IS_WIN32 FALSE
  22. #endif
  23.  
  24. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  25. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  26. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  27.  
  28. LPCTSTR lpszAppName = "lineBlindTransfer";
  29. LPCTSTR lpszTitle   = "lineBlindTransfer"; 
  30.  
  31. HINSTANCE hInst;   // current instance
  32. HWND hWnd;         // parent window handle
  33. HWND hListWnd;     // listbox
  34. HDC  hdc;
  35. TEXTMETRIC  tm ;
  36.  
  37. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  38.  
  39.  
  40. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  41.                       LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43.    MSG      msg;
  44.    WNDCLASS wc;
  45.  
  46.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  47.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  48.    wc.cbClsExtra    = 0;                      
  49.    wc.cbWndExtra    = 0;                      
  50.    wc.hInstance     = hInstance;              
  51.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  52.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  53.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  54.    wc.lpszMenuName  = lpszAppName;              
  55.    wc.lpszClassName = lpszAppName;              
  56.  
  57.    if ( IS_WIN95 )
  58.    {
  59.       if ( !RegisterWin95( &wc ) )
  60.          return( FALSE );
  61.    }
  62.    else if ( !RegisterClass( &wc ) )
  63.       return( FALSE );
  64.  
  65.    hInst = hInstance; 
  66.  
  67.    hWnd = CreateWindow( lpszAppName, 
  68.                         lpszTitle,    
  69.                         WS_OVERLAPPEDWINDOW, 
  70.                         CW_USEDEFAULT, 0, 
  71.                         CW_USEDEFAULT, 0,  
  72.                         NULL,              
  73.                         NULL,              
  74.                         hInstance,         
  75.                         NULL               
  76.                       );
  77.  
  78.    if ( !hWnd ) 
  79.       return( FALSE );
  80.  
  81.    ShowWindow( hWnd, nCmdShow ); 
  82.    UpdateWindow( hWnd );         
  83.  
  84.    while( GetMessage( &msg, NULL, 0, 0) )   
  85.    {
  86.       TranslateMessage( &msg ); 
  87.       DispatchMessage( &msg );  
  88.    }
  89.  
  90.    return( msg.wParam ); 
  91. }
  92.  
  93.  
  94. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  95. {
  96.     WNDCLASSEX wcex;
  97.  
  98.    wcex.style         = lpwc->style;
  99.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  100.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  101.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  102.    wcex.hInstance     = lpwc->hInstance;
  103.    wcex.hIcon         = lpwc->hIcon;
  104.    wcex.hCursor       = lpwc->hCursor;
  105.    wcex.hbrBackground = lpwc->hbrBackground;
  106.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  107.    wcex.lpszClassName = lpwc->lpszClassName;
  108.  
  109.    // Added elements for Windows 95.
  110.    //...............................
  111.    wcex.cbSize = sizeof(WNDCLASSEX);
  112.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  113.                             IMAGE_ICON, 16, 16,
  114.                             LR_DEFAULTCOLOR );
  115.             
  116.    return RegisterClassEx( &wcex );
  117. }
  118.  
  119. #define CONFCALL    1
  120. #define CONSULT      2
  121.  
  122. enum CallState
  123. {
  124.     Idle,
  125.     Offering,
  126.     Accepted,
  127.     Dialtone,
  128.     Dialing,
  129.     Ringback,
  130.     Busy,
  131.     Special,
  132.     Connected,
  133.     Proceeding,
  134.     Conferenced,
  135.     Onholdconf,
  136.     Disconnected,
  137.     Unknown
  138. };
  139.  
  140. typedef struct tagMYINFO      // general application information
  141. {
  142.     HLINEAPP lineApp;         // instance handle TAPI gives back to us                                                                              through lineInitialize()
  143.     DWORD dwNumDevices;       // number of available devices
  144.     DWORD dwAPIVersion;       // API version the line supports
  145.      DWORD dwExtVersion;           // extended version
  146.     char szLocation[128];     // location        
  147.      char szCallingCard[128];  // calling card being used
  148.     char szAreaCode[4];       // area code       
  149.     char szCountry[128];      // calling card being used
  150. } MYINFO;
  151.  
  152. typedef struct tagLINEINFO  // information on an open line
  153. {
  154.     DWORD dwNumAddress;     // number of available addresses on the line 
  155.     HLINE hLine;            // handle to the line as returned by lineOpen 
  156.      DWORD dwLineID;         // the line ID of this line
  157.     char  szLineName[128];  // the line's name 
  158.  
  159. } MYLINEINFO;
  160.  
  161. typedef struct tagMYCALLINFO  //information on a call                     
  162. {
  163.     
  164. DWORD       eCallState;    // TAPI's line call State, set as user-defined enums
  165. DWORD      dwRequestID;   // requestID returned by async TAPI functions lineMakeCall/lineDropCall
  166. DWORD      dwAddressID;   // the originating address ID of the call being made 
  167. LPCSTR     lpszAddress;    
  168. HLINE     hLine;         // handle to the line 
  169. HCALL        hCall;         // handle to the call 
  170.    
  171. char szDialString[TAPIMAXDESTADDRESSSIZE];  //phone number being dialed
  172. char szDialStringOriginal[TAPIMAXDESTADDRESSSIZE];
  173. char szDialStringCanonical[TAPIMAXDESTADDRESSSIZE];
  174. char szCalledParty[TAPIMAXCALLEDPARTYSIZE]; // name of the party
  175. DWORD dwTranslateResults;
  176.         
  177. } MYCALLINFO;
  178.  
  179. enum CallAction     // Declare enum type CallAction (used in lineSetAppSpecific)
  180. {
  181.    HOLD,            // hold the call
  182.    TRANSFER,        // transfer the call
  183.    REDIRECT,        // redirect the call
  184.    DROP,            // drop the call
  185.    PARK             // park the call
  186. }; 
  187.  
  188. MYINFO myInfo;          //instance of MYINFO structure
  189. MYLINEINFO myLineInfo[MAX_LINE];  //instance of MYLINEINFO structure
  190. MYCALLINFO myCallInfo[MAX_CALL]; //array of MYCALLINFO strcuture
  191.  
  192. LONG lRet;        //return code
  193. char buf[BUFSIZE];    // buffer for debug message
  194.  
  195. DWORD dwLineID = 0;
  196. DWORD i;
  197. LINEEXTENSIONID        ext_id;
  198. LINEDEVCAPS            *plineDevCaps;
  199. LINEADDRESSCAPS        *plineAdddressCaps;
  200. LINEADDRESSSTATUS     *plineAddressStat;
  201. LINECALLINFO            *plineCallInfo;
  202. LINECALLSTATUS         *plineCallStatus;
  203. LINECALLLIST            *plineCallList;
  204. LINEDEVSTATUS           *plineDevStatus;
  205. LINETRANSLATECAPS       *plineTranslateCaps;
  206. LINETRANSLATEOUTPUT  *plineTranslateOutput;
  207. LINECALLPARAMS           *plineCallParams;
  208. LINEDEVSTATUS           *plineDevStatus;
  209. LINEFORWARDLIST        *plineForwardList;
  210. LINETRANSLATECAPS       *plineTranslateCaps;
  211. LINEREQMAKECALL       lineReqMakeCall;
  212. VARSTRING               *pDeviceConfig;
  213. VARSTRING               *pDeviceId;
  214. VARSTRING               *pNonDirAddress;
  215.  
  216. LPLINELOCATIONENTRY  lineLocEntry;
  217. LPLINECARDENTRY        lineCardEntry;
  218. LINECOUNTRYLIST         *plineCountryList;
  219. LPLINECOUNTRYENTRY   lineCE;
  220.  
  221. LPSTR                lpData;
  222.  
  223. HICON                hIcon = NULL;        //used in lineGetID();
  224. DWORD                dwNumRings;    //used in lineGetNumRings();
  225. HCALL                hConsultCall; //handle to consultation linePrepareAddToConference, SetupConference
  226. HCALL                hConfCall; //handle to consultation linePrepareAddToConference, SetupConference   
  227. HCALL                hParkedCall;
  228.  
  229. DWORD                dwCompletionID;  //used in lineCompleteCall()
  230.  
  231. char                szName[128];
  232. char                szNumber[128];
  233. char                szDigits[128];
  234. char                szDevConfig[128];
  235.  
  236. LONG lRet;
  237. char buf[BUFSIZE];
  238.  
  239. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  240. {
  241.    switch( uMsg )
  242.    {
  243.       case WM_COMMAND :
  244.          switch( LOWORD( wParam ) )
  245.          {
  246.             case IDM_RUN :
  247.                DialogBox( hInst, "IDD_DIALNUM", hWnd, (DLGPROC)Dial );
  248.                break;                      
  249.             
  250.             case IDM_ABOUT :
  251.             {
  252.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  253.                break;
  254.             }
  255.  
  256.             case IDM_EXIT :
  257.             {
  258.                for (i = 0; i < myInfo.dwNumDevices; i++)
  259.                        lineClose(myLineInfo[i].hLine);
  260.                     lineShutdown(myInfo.lineApp);
  261.                DestroyWindow( hWnd );
  262.                break;
  263.             }
  264.             }                  
  265.                  
  266.          break;
  267.  
  268.       case WM_CREATE :
  269.       {
  270.          hdc = GetDC (hWnd) ;
  271.          GetTextMetrics (hdc, &tm) ;
  272.          ReleaseDC (hWnd, hdc) ;
  273.  
  274.          hListWnd = CreateWindowEx( 0, "listbox", 
  275.                         " ",    
  276.                         WS_CHILD | WS_VISIBLE,  
  277.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  278.                         tm.tmAveCharWidth * 16 +
  279.                                    GetSystemMetrics (SM_CXVSCROLL), 
  280.                         tm.tmHeight * 5,  
  281.                         hWnd,              
  282.                         NULL,              
  283.                         hInst,         
  284.                         NULL               
  285.                         );
  286.  
  287.          
  288.          //lineInitialize
  289.             //...............................................
  290.          lRet = lineInitialize(&myInfo.lineApp, hInst, lineCallback, NULL, &myInfo.dwNumDevices);
  291.          if (lRet == 0) 
  292.          {
  293.             wsprintf (buf, "lineInitialize suceeded!");
  294.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  295.            }
  296.          else 
  297.           {
  298.                wsprintf ( buf,"lineInitialize failed, err=x%lx",lRet);
  299.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  300.                lineError(lRet);
  301.                break;
  302.          }                    
  303.          
  304.          //lineNegotiateAPIVersion
  305.           //...............................................
  306.          lRet = lineNegotiateAPIVersion(myInfo.lineApp, 0, APILOWVERSION, APIHIVERSION, 
  307.                                            &myInfo.dwAPIVersion, &ext_id);
  308.          if (lRet == 0)                        
  309.          {
  310.             wsprintf (buf, "lineNegotiateAPIVersion suceeded!");
  311.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  312.          }
  313.          else 
  314.           {
  315.                wsprintf (buf, "lineNegotiateAPIVersion failed, err=x%lx",
  316.                            lRet);
  317.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  318.                lineError(lRet);
  319.                lineShutdown (myInfo.lineApp);
  320.             break;
  321.          }
  322.  
  323.           //lineNegotiateExtVersion
  324.           //...............................................
  325.          lRet = lineNegotiateExtVersion(myInfo.lineApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  326.                                            EXTHIVERSION, &myInfo.dwExtVersion);
  327.          if (lRet == 0)                        
  328.          {
  329.             wsprintf (buf, "lineNegotiateExtVersion suceeded!");
  330.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  331.  
  332.          }
  333.           else 
  334.           {
  335.                wsprintf (buf, "lineNegotiateExtVersion failed, err=x%lx",
  336.                      lRet);
  337.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  338.               lineError(lRet);
  339.       
  340.          }
  341.  
  342.           //lineGetDevCaps
  343.           //for each line device, get capabilities until we find one that supports
  344.          //interactive voice 
  345.           //...............................................
  346.          plineDevCaps = (LINEDEVCAPS *) calloc (1, sizeof(LINEDEVCAPS)+1000);
  347.          plineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS) + 1000;
  348.          for (i = 0; i < myInfo.dwNumDevices; i++)
  349.          {
  350.             lineGetDevCaps(myInfo.lineApp, i, myInfo.dwAPIVersion, 0, plineDevCaps);
  351.             if (plineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) 
  352.             {
  353.                
  354.                myLineInfo[i].dwNumAddress = plineDevCaps->dwNumAddresses;
  355.                   myLineInfo[i].dwLineID = i;
  356.                    if (plineDevCaps->dwLineNameSize > 0)
  357.                           strcpy(myLineInfo[i].szLineName,((LPSTR)(plineDevCaps)+plineDevCaps->dwLineNameOffset));
  358.              }
  359.           }
  360.  
  361.          //lineOpen
  362.           //................................................................
  363.           lRet = lineOpen(myInfo.lineApp,myLineInfo[OWNER].dwLineID,&myLineInfo[OWNER].hLine,
  364.                            myInfo.dwAPIVersion,0,(DWORD)lineCallback, LINECALLPRIVILEGE_NONE,
  365.                             LINEMEDIAMODE_DATAMODEM, NULL);
  366.           if (lRet == 0)
  367.           {
  368.             wsprintf (buf, "lineOpen suceeded!");
  369.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;         }
  370.            else 
  371.            {
  372.                wsprintf ( buf,"lineOpen failed, err=x%lx", lRet);
  373.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  374.                lineError(lRet);
  375.           }
  376.        
  377.          break;
  378.       }
  379.       
  380.       case WM_SIZE:
  381.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  382.          break;
  383.  
  384.       case WM_DESTROY :
  385.               PostQuitMessage(0);
  386.               break;
  387.  
  388.       default :
  389.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  390.    }
  391.  
  392.    return( 0L );
  393. }
  394.  
  395.  
  396.  
  397. /****************************************************************************
  398.     FUNCTION: lineCallback
  399.     PURPOSE:  callback function handles line events
  400. ****************************************************************************/
  401. LRESULT CALLBACK lineCallback (DWORD dwDevice, DWORD dwMsg,
  402.                                        DWORD dwCallbackInst, DWORD dwParam1,
  403.                                        DWORD dwParam2,DWORD dwParam3)
  404. {
  405.    switch (dwMsg)
  406.    {
  407.       case LINE_CALLSTATE:
  408.       {
  409.          for (i = 0; i < MAX_CALL; i++)
  410.          {
  411.             if (dwDevice = (DWORD) myCallInfo[i].hCall) 
  412.                switch (dwParam1)
  413.                {
  414.                   case LINECALLSTATE_IDLE:
  415.                      myCallInfo[i].eCallState = Idle;
  416.                      break;
  417.                   
  418.                   case LINECALLSTATE_OFFERING:
  419.                      myCallInfo[i].eCallState = Offering;
  420.                      break;
  421.                
  422.                         case LINECALLSTATE_ACCEPTED:
  423.                            myCallInfo[i].eCallState = Accepted;
  424.                            break;
  425.                     
  426.                        case LINECALLSTATE_DIALTONE:
  427.                            myCallInfo[i].eCallState = Dialtone;
  428.                      break;
  429.                     
  430.                        case LINECALLSTATE_DIALING:
  431.                            myCallInfo[i].eCallState = Dialing;
  432.                            break;
  433.                   
  434.                      case LINECALLSTATE_RINGBACK:
  435.                            myCallInfo[i].eCallState = Ringback;
  436.                            break;
  437.             
  438.                        case LINECALLSTATE_BUSY:
  439.                            myCallInfo[i].eCallState = Busy;
  440.                            break;
  441.             
  442.                        case LINECALLSTATE_SPECIALINFO:
  443.                            myCallInfo[i].eCallState = Special;
  444.                           break;
  445.             
  446.                         case LINECALLSTATE_CONNECTED:
  447.                      myCallInfo[i].eCallState = Connected;
  448.                      //call lineBlindTransfer
  449.                      //...............................
  450.                      strcpy(myCallInfo[0].szDialString, "T5012100"); //from user
  451.                      lRet = lineBlindTransfer(myCallInfo[0].hCall,  
  452.                                               myCallInfo[0].szDialString, 0);
  453.                      if (lRet > 0)
  454.                      {
  455.                         wsprintf (buf,"lineBlindTransfer succeeded!");
  456.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  457.  
  458.                      }
  459.                      else 
  460.                      {
  461.                         wsprintf (buf,"lineBlindTransfer failed,err=x%lx", lRet);
  462.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  463.                         lineError(lRet);
  464.                      }
  465.                      break;
  466.  
  467.                        case LINECALLSTATE_PROCEEDING:
  468.                            myCallInfo[i].eCallState = Proceeding;
  469.                           break;
  470.             
  471.                        case LINECALLSTATE_CONFERENCED:
  472.                            myCallInfo[i].eCallState = Conferenced;
  473.                           break;
  474.             
  475.                        case LINECALLSTATE_ONHOLDPENDCONF:
  476.                            break;
  477.                 
  478.                   case LINECALLSTATE_DISCONNECTED:
  479.                            myCallInfo[i].eCallState = Disconnected;
  480.                           break;
  481.             
  482.                        case LINECALLSTATE_UNKNOWN:
  483.                            myCallInfo[i].eCallState = Unknown;
  484.                           break;
  485.        
  486.              }
  487.           }
  488.        }
  489.  
  490.        case LINE_MONITORMEDIA:
  491.            break;
  492.  
  493.        case LINE_MONITORDIGITS:
  494.           break;
  495.  
  496.          case LINE_MONITORTONE:
  497.           break;
  498.    
  499.        //error handling for functions completed asynchronously
  500.         //.....................................................
  501.        case LINE_REPLY:
  502.         {
  503.             for (i = 0; i < MAX_CALL; i++)
  504.            {
  505.                 if (dwParam1 = myCallInfo[i].dwRequestID)
  506.                {
  507.                    if (dwParam2 != 0)
  508.                    {
  509.                        lineError((LONG) dwParam2);
  510.                        break;
  511.                    }
  512.                }
  513.            }
  514.         break;
  515.         }
  516.  
  517.         case LINE_GENERATE:
  518.           break;
  519.      
  520.        case LINE_REQUEST:
  521.          break;
  522.  
  523.         case LINE_GATHERDIGITS:
  524.            break;
  525.    }
  526.  
  527.    return (TRUE);
  528.  
  529.  
  530. /****************************************************************************
  531.     FUNCTION: lineError
  532.     PURPOSE:  line error messages
  533. ****************************************************************************/
  534. void lineError (LONG lrc)
  535. {
  536.  switch (lrc) {
  537.     case LINEERR_INVALAPPHANDLE:
  538.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  539.        break;
  540.     case LINEERR_BADDEVICEID:
  541.        MessageBox (hWnd,"The specified line device ID is out of range.", "", 
  542.                    MB_OK);
  543.        break;
  544.     case LINEERR_INCOMPATIBLEAPIVERSION:
  545.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  546.        break;
  547.     
  548.     case LINEERR_ADDRESSBLOCKED:
  549.        MessageBox (hWnd, "Address was blocked.", "", MB_OK);
  550.        break;
  551.  
  552.     case LINEERR_BEARERMODEUNAVAIL:
  553.        MessageBox (hWnd, "Bearer Mode Unavailable.", "", MB_OK);
  554.        break;
  555.  
  556.     case LINEERR_CALLUNAVAIL:
  557.        MessageBox (hWnd, "Call appearances in use..", "", MB_OK);
  558.        break;
  559.  
  560.     case LINEERR_INUSE:
  561.        MessageBox (hWnd, "Line in Use.", "", MB_OK);
  562.        break;
  563.     
  564.     case LINEERR_INVALADDRESS:
  565.        MessageBox (hWnd, "Invalid Address.", "", MB_OK);
  566.        break;
  567.  
  568.     case LINEERR_INVALADDRESSID:
  569.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  570.        break;
  571.  
  572.     case LINEERR_INVALCALLPARAMS:
  573.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  574.        break;
  575.      
  576.     case LINEERR_INCOMPATIBLEEXTVERSION:
  577.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  578.        break;
  579.     case LINEERR_NOMEM:
  580.        MessageBox (hWnd, "No memory","", MB_OK);
  581.        break;
  582.     case LINEERR_NODRIVER:
  583.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  584.        break;
  585.     case LINEERR_RESOURCEUNAVAIL:
  586.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  587.        break;
  588.     case LINEERR_INVALPRIVSELECT:
  589.        MessageBox (hWnd, "Requested invalid priviledges", "", MB_OK);
  590.        break;
  591.     case LINEERR_INVALMEDIAMODE:
  592.        MessageBox (hWnd, "Requested invalid media mode", "", MB_OK);
  593.        break;
  594.     case LINEERR_LINEMAPPERFAILED:
  595.        MessageBox (hWnd, "Line mapper failed", "", MB_OK);
  596.        break;
  597.     case LINEERR_INVALPOINTER:
  598.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  599.                    "", MB_OK);
  600.        break;
  601.     case LINEERR_OPERATIONFAILED:
  602.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  603.        break;
  604.     case LINEERR_INVALLINEHANDLE:
  605.        MessageBox (hWnd, "Invalid line handle", "", MB_OK);
  606.        break;
  607.     case LINEERR_INVALCALLHANDLE:
  608.        MessageBox (hWnd, "Invalid call handle", "", MB_OK);
  609.        break;
  610.     case LINEERR_INVALCALLSELECT:
  611.        MessageBox (hWnd, "Invalid call selection", "", MB_OK);
  612.        break;
  613.     case LINEERR_NODEVICE:
  614.        MessageBox (hWnd, "No associated device for given class",
  615.                    "", MB_OK);
  616.        break;
  617.     case LINEERR_OPERATIONUNAVAIL:
  618.        MessageBox (hWnd, "The operation is unavailable",
  619.                    "", MB_OK);
  620.        break;
  621.     case LINEERR_INVALPARAM:
  622.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  623.        break; 
  624.  
  625.     case LINEERR_TARGETNOTFOUND:
  626.         MessageBox(hWnd, "Target Not Found", "", MB_OK);
  627.        break; 
  628.  
  629.    case LINEERR_NOREQUEST:
  630.       MessageBox(hWnd, "No outstanding Assisted Telephony requests.", "", MB_OK);
  631.        break; 
  632.    }
  633. }
  634.  
  635. LRESULT CALLBACK Dial ( HWND hDlg,           // window handle of the dialog box
  636.                         UINT message,        // type of message
  637.                         WPARAM wParam,       // message-specific information
  638.                         LPARAM lParam)
  639. {
  640.    switch (message) 
  641.    {
  642.        case WM_INITDIALOG:  // message: initialize dialog box
  643.                return (TRUE);
  644.  
  645.        case WM_COMMAND:                              // message: received a command
  646.          if (   LOWORD(wParam) == IDOK )        // "OK" box selected?
  647.          {
  648.             GetDlgItemText(hDlg, IDC_NAME, szName, 128);
  649.                 GetDlgItemText(hDlg, IDC_NUMBER, szNumber, 128);
  650.                                       
  651.  
  652.                 // put up a dialog box to obtain a string to dial from the user
  653.                //...........................................................
  654.                strcpy(myCallInfo[0].szDialStringOriginal, szNumber); 
  655.                
  656.                //allocate buffer for the LINEADDRESSCAPS strucuture 
  657.                //...................................................
  658.                plineTranslateOutput = (LINETRANSLATEOUTPUT *) calloc (1, sizeof(LINETRANSLATEOUTPUT)+1000);
  659.             plineTranslateOutput->dwTotalSize = sizeof(LINETRANSLATEOUTPUT) + 1000;
  660.               
  661.                // translate the Address to a dialable address and Canonical address
  662.                //.....................................................................
  663.                lRet = lineTranslateAddress(myInfo.lineApp, myLineInfo[OWNER].dwLineID, myInfo.dwAPIVersion,
  664.                                            myCallInfo[0].szDialStringOriginal, 0, 0, plineTranslateOutput);
  665.                               
  666.                if (lRet == 0)
  667.                {
  668.                        
  669.                    strncpy(myCallInfo[0].szDialString, (LPSTR)(plineTranslateOutput)
  670.                             + plineTranslateOutput->dwDialableStringOffset,
  671.                              plineTranslateOutput->dwDialableStringSize); 
  672.     
  673.                     strncpy(myCallInfo[0].szDialStringCanonical,(LPSTR)(plineTranslateOutput) 
  674.                             + plineTranslateOutput->dwDisplayableStringOffset,
  675.                             plineTranslateOutput->dwDisplayableStringSize); 
  676.                                            
  677.                    myCallInfo[0].dwTranslateResults = plineTranslateOutput->dwTranslateResults;
  678.                 }
  679.  
  680.                else 
  681.                {
  682.                     wsprintf ( buf,"lineTranslateAddress failed, err=x%lx", lRet);
  683.                     lineError(lRet);
  684.                    break;
  685.             }
  686.            
  687.                //lineMakeCall
  688.                //................................................................
  689.                           
  690.                plineCallParams = (LINECALLPARAMS *) calloc (1, sizeof(LINECALLPARAMS)+1000);
  691.             plineCallParams->dwTotalSize = sizeof(LINECALLPARAMS) + 1000;
  692.  
  693.                plineCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
  694.                plineCallParams->dwMediaMode =  LINEMEDIAMODE_DATAMODEM;
  695.                plineCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
  696.                plineCallParams->dwAddressMode    = LINEADDRESSMODE_ADDRESSID;
  697.                plineCallParams->dwAddressID    = 0;
  698.                plineCallParams->dwMinRate    = 1200;
  699.                plineCallParams->dwMaxRate    = 2400;
  700.                             
  701.                lRet = lineMakeCall(myLineInfo[OWNER].hLine,&myCallInfo[0].hCall, 
  702.                                       myCallInfo[0].szDialString ,0,  plineCallParams);
  703.            
  704.             if (lRet > 0)
  705.                {
  706.                wsprintf (buf, "lineMakeCall suceeded!");
  707.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  708.                    myCallInfo[0].dwRequestID = lRet;
  709.                 }
  710.             else 
  711.                {
  712.                    wsprintf ( buf,"lineMakeCall failed, err=x%lx", lRet);
  713.                     lineError(lRet);
  714.                    break;
  715.             }
  716.             
  717.             EndDialog(hDlg, TRUE);        // Exit the dialog
  718.             return (TRUE);
  719.          }
  720.  
  721.             if (   LOWORD(wParam) == IDCANCEL)         // "OK" box selected?
  722.          {
  723.             EndDialog(hDlg, TRUE);        // Exit the dialog
  724.             return (TRUE);
  725.          }
  726.          break;
  727.  
  728.  
  729.    }
  730.  
  731.    return (FALSE); 
  732. }
  733.  
  734. LRESULT CALLBACK About( HWND hDlg,           
  735.                         UINT message,        
  736.                         WPARAM wParam,       
  737.                         LPARAM lParam)
  738. {
  739.    switch (message) 
  740.    {
  741.        case WM_INITDIALOG: 
  742.                return (TRUE);
  743.  
  744.        case WM_COMMAND:                              
  745.                if (   LOWORD(wParam) == IDOK         
  746.                    || LOWORD(wParam) == IDCANCEL)    
  747.                {
  748.                        EndDialog(hDlg, TRUE);        
  749.                        return (TRUE);
  750.                }
  751.                break;
  752.    }
  753.  
  754.    return (FALSE); 
  755. }
  756.  
  757.  
  758.